$(".sidebar-elements li.parent").click(function(){
    var currentMenu = $(this).addClass('open').siblings().removeClass('open');;
})

function targetMenu()
{
    var currentMenu = $('.sidebar-elements a[href="'+window.location.pathname+'"]:first');
    if (currentMenu) {
        var liparent = currentMenu.closest('li.parent');
        return liparent.addClass('open').siblings().removeClass('open');
    };
}

targetMenu();
